package cn.gdut.chengcai.base;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * ID生成器
 *
 */
public class IdGenerator {
	/**
	 * 文章编号，19位字符：A1+年月日时分秒（12）+随机数（5）
	 */
	public static String generatorArticleSn() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyMMddhhmmss");
		Random random = new Random();
		String ramdonString = String.format("%05d", random.nextInt(100000));
		return "A1" + sdf.format(new Date()) + ramdonString;
	}

	/**
	 * 课程编号，19位字符：C1+年月日时分秒（12）+随机数（5）
	 */
	public static String generatorCourseSn() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyMMddhhmmss");
		Random random = new Random();
		String ramdonString = String.format("%05d", random.nextInt(100000));
		return "C1" + sdf.format(new Date()) + ramdonString;
	}

	/**
	 * 生涯编号，19位字符：C2+年月日时分秒（12）+随机数（5）
	 */
	public static String generatorCareerSn() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyMMddhhmmss");
		Random random = new Random();
		String ramdonString = String.format("%05d", random.nextInt(100000));
		return "C2" + sdf.format(new Date()) + ramdonString;
	}

	/**
	 * 生涯任务编号，19位字符：C3+年月日时分秒（12）+随机数（5）
	 */
	public static String generatorCareerTaskSn() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyMMddhhmmss");
		Random random = new Random();
		String ramdonString = String.format("%05d", random.nextInt(100000));
		return "C3" + sdf.format(new Date()) + ramdonString;
	}

	/**
	 * 试卷编号，19位字符：E1+年月日时分秒（12）+随机数（5）
	 */
	public static String generatorExamSn() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyMMddhhmmss");
		Random random = new Random();
		String ramdonString = String.format("%05d", random.nextInt(100000));
		return "E1" + sdf.format(new Date()) + ramdonString;
	}

	/**
	 * 会员编号，19位字符：M1+年月日时分秒（12）+随机数（5）
	 */
	public static String generatorMemberSn() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyMMddhhmmss");
		Random random = new Random();
		String ramdonString = String.format("%05d", random.nextInt(100000));
		return "M1" + sdf.format(new Date()) + ramdonString;
	}

	/**
	 * 普通编号，19位字符：N1+年月日时分秒（12）+随机数（5）
	 */
	public static String generatorNormalSn() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyMMddhhmmss");
		Random random = new Random();
		String ramdonString = String.format("%05d", random.nextInt(100000));
		return "N1" + sdf.format(new Date()) + ramdonString;
	}

	/**
	 * 订单编号，19位字符：O1+年月日时分秒（12）+随机数（5）
	 */
	public static String generatorOrderSn() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyMMddhhmmss");
		Random random = new Random();
		String ramdonString = String.format("%05d", random.nextInt(100000));
		return "O1" + sdf.format(new Date()) + ramdonString;
	}

	/**
	 * 简历编号，19位字符：R1+年月日时分秒（12）+随机数（5）
	 */
	public static String generatorResumeSn() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyMMddhhmmss");
		Random random = new Random();
		String ramdonString = String.format("%05d", random.nextInt(100000));
		return "R1" + sdf.format(new Date()) + ramdonString;
	}

	/**
	 * 合作伙伴编号，19位字符：P1+年月日时分秒（12）+随机数（5）
	 */
	public static String generatorPartnerSn() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyMMddhhmmss");
		Random random = new Random();
		String ramdonString = String.format("%05d", random.nextInt(100000));
		return "P1" + sdf.format(new Date()) + ramdonString;
	}

	public static void main(String[] args) {
		for (int i = 0; i < 5; i++) {
			System.out.println(generatorOrderSn());
		}
	}
}
